import re
from pprint import pprint

filename = r"function\function.md"
prefix = "fn"


def number_lines(lines):
    num = 0
    for line in lines:
        if line.lower().startswith("### " + prefix.lower()):
            num += 1
            yield f"### {prefix.upper()}-{num:03d}\n"
        else:
            yield line


with open(filename, encoding="utf-8") as file:
    lines = file.readlines()

lines = list(number_lines(lines))

with open(filename, encoding="utf-8", mode="w") as file:
    file.writelines(lines)
